package org.ecjmn.pringles.game;

import java.util.Collections;
import java.util.Iterator;
import java.util.Vector;

public class Hand {
	private Vector<Integer> thisHand;
	
	public Hand() {
		thisHand = new Vector<Integer>(); 
	}
	
	public void put(int card) {
		thisHand.add(card);
	}
	
	public void print() {
		System.out.println(thisHand.toString());
	}
	
	public void shuffle() {
		Collections.shuffle(thisHand);
	}
	
	public int valueWithAIs1() {
		int valueSum = 0;
		 Iterator ita=thisHand.iterator();
         while(ita.hasNext())
         {
               Integer intObj = (Integer)ita.next();
               valueSum += intObj.intValue();
         }
         return valueSum;
	}
	
	public int valueWithAIs11() {
		int valueSum = 0;
		 Iterator ita=thisHand.iterator();
         while(ita.hasNext())
         {
               Integer intObj = (Integer)ita.next();
               if (intObj.intValue()==1){
            	   valueSum += 11;
               }
               else {
            	   valueSum += intObj.intValue();
               }
         }
         return valueSum;
	}
	
	public Vector<Integer> getVector() {
		return thisHand;
	}
	
	public int topValue() {
		return thisHand.firstElement();
	}
}
